package main

import (
	"gopkg.in/olivere/elastic.v5"
	"goruntimeDistributionCrawler/config"
	"goruntimeDistributionCrawler/rpcsuport"
	"goruntimeDistributionCrawler/saveservice"
)

/**
*发起微服务 保存  服务注册
 */
func main() {
	err := regsterService(config.SAVE_HOST_PROT, config.DATA_BASES_INDEX)
	if err != nil {
		panic(err)
	}
}

func regsterService(host string, index string) error {
	clientLink,err:=elastic.NewClient(
		elastic.SetURL(config.DATA_BASES_URL),
		elastic.SetSniff(false),
	)
	if err!=nil{
		return err
	}
	return rpcsuport.ServeRpc(host,
		&saveservice.ItemSaveService{
			Client:clientLink,
			Index:index,
		})

}
